package com.qcxk.yuqian.system.component.token.admin;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AdminLoginInterceptorConfig implements WebMvcConfigurer {

    @Bean
    public HandlerInterceptor getAdminTokenInterceptor() {
        return new AdminTokenInterceptor();
    }

    //    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry){
//        registry.addResourceHandler("/img/**").addResourceLocations("classpath:/static/img/");
//    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TokenInterceptor拦截器
        InterceptorRegistration registration = registry.addInterceptor(getAdminTokenInterceptor());
        registration.addPathPatterns("/**");                      //所有路径都被拦截
        registration.excludePathPatterns(                         //添加不拦截路径
                "/bnsStores/queryBnsStoresListForFront",            //前端查询店铺列表
                "/bnsStores/loadBnsStoresFront",            //前端查询店铺列表
                "/bnsUserextra/getUserAmount",
                "/bnsUsers/chgPayPassword",
                "/bnsPaymentrecord/cz",
                "/bnsPaymentrecord/tx",
                "/bnsTraderecord/reserveAndBuy",
                "/bnsUsers/chgLoginPassword",
                "/bnsTraderecord/queryTraderecordListFront",
                "/bnsPaymentrecord/queryPaymentrecordListFront",
                "/taobaoDetail",
                "/tmallDetail",
                "/front_resetPWD",
                "/front_resetPWDPage",
                "/front_chkUserSendValidateCode",
                "/qiyeDetail",
                "/chkUserSendValidateCode",
                "/frontExit",
                "/exit",            //后端用户退出登录
                "/login",            //前端用户登录
                "/testUser",            //前端用户登录
                "/manage",            //前端用户管理
                "/front_login",            //前端用户登录
                "/index",           //首页
                "/taobao",           //淘宝
                "/qiye",           //企业
                "/shopsell",           //网店估价
                "/bnsStores/getOwnerQQ",           //获得客服信息
                "/bnsEvaluation/addBnsEvaluation",  //提交估价信息
                "/tmall",           //首页
                "/header",          //头部
                "/chgHotwords",
                "/headerData",          //头部数据
                "/getIndexStore",          //首页推荐数据
                "/shopsell",          //网店估价
                "/taobao",          //淘宝
                "/tmail",          //天猫
                "/footer",          //尾部
                "/loginByAdmin",            //后端员工登录
                "/register",            //用户注册
                "/front_register",            //用户注册
                "/lostPWD",            //忘记密码
                "/resetPWD",            //重置密码
                "/checkValidateCode", //校验验证码
                "/**/*.html",            //html静态资源
                "/img/**",            //图片
                "/**/*.png",              //js静态资源
                "/**/*.gif",              //js静态资源
                "/**/*.js",              //js静态资源
                "/**/*.css",             //css静态资源
                "/**/*.woff",
                "/**/*.woff2",
                "/**/*.ttf",
                "/downloadApply/downLoad", //下载文件,
                "/word/exportWord" //导出Word
        );

    }
}
